package org.vuzya.motivateme.activities;

import static org.vuzya.motivateme.helpers.ConstantHelper.EXTRA_BUSINESS_ID;
import static org.vuzya.motivateme.helpers.ConstantHelper.EXTRA_MOTIVATION_ANSWERS;

import org.vuzya.motivateme.R;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;

public class SummaryActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_summary);
		
		LinearLayout ll = (LinearLayout)findViewById(R.id.test_summary_linearlayout);
		LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
		TextView tv;
		
		String[] answers = getIntent().getStringArrayExtra(EXTRA_MOTIVATION_ANSWERS);
		String[] questions = getResources().getStringArray(R.array.question_titles);
		
		for(int i = 0; i < answers.length; i++){
			tv = new TextView(this);
			tv.setLayoutParams(params);
			tv.setText(questions[i]);
			tv.setTypeface(Typeface.DEFAULT_BOLD);
			ll.addView(tv);
			
			tv = new TextView(this);
			tv.setLayoutParams(params);
			tv.setText(answers[i]);
			tv.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
			ll.addView(tv);
		}
	}
	
	public void gotoInfo(View v){
		Intent i = new Intent(this, ReadMoreActivity.class);
		startActivity(i);
		finish();
	}
	
	public void gotoTable(View v){
		Intent i = new Intent(this, TableActivity.class);
		i.putExtra(EXTRA_BUSINESS_ID, getIntent().getLongExtra(EXTRA_BUSINESS_ID, -1));
		startActivity(i);
		finish();
	}
}
